<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class IndexController extends Controller
{
    public function getIndex()
    {
    	$nansheng = DB::table('hs_books')
    	->join('hs_member','hs_books.id','=','hs_member.id')
    	->select('hs_books.*','hs_member.name')
    	->where('hs_member.make','=',1)
    	->where('hs_books.men','=',0)
    	->paginate(10);
    	$a = 1;	
    	foreach($nansheng as $k=>$v)
    	{

    		$nansheng[$k]->num = $a;	

    		$a ++;
    	}
    	
 		 //dd($nansheng);
    		
    	$nvsheng = DB::table('hs_books')
    	->join('hs_member','hs_books.id','=','hs_member.id')
    	->select('hs_books.*','hs_member.name')
    	->where('hs_member.make','=',1)
    	->where('hs_books.men','=',1)
    	->paginate(10);
    	$a = 1;	
    	foreach($nvsheng as $k=>$v)
    	{

    		$nvsheng[$k]->num = $a;	
    		
    		$a ++;
    	}
    	

    	$dasheng = DB::table('hs_books')
    	->join('hs_member','hs_books.id','=','hs_member.id')
    	->select('hs_books.*','hs_member.name')
    	->where('hs_member.make','=',1)
    	->where('hs_books.isend','=',1)
    	->paginate(6);
    


    	$wanjie = DB::table('hs_books')
    	->join('hs_member','hs_books.id','=','hs_member.id')
    	->select('hs_books.*','hs_member.name')
    	->where('hs_member.make','=',1)
    	->where('hs_books.isend','=',0)
    	->paginate(6);
    	

    	$nanping = DB::table('hs_books')
    	->join('hs_member','hs_books.id','=','hs_member.id')
    	->select('hs_books.*','hs_member.name')
    	->where('hs_member.make','=',1)
    	->where('hs_books.men','=',0)
    	->paginate(6);


    	$nvping = DB::table('hs_books')
    	->join('hs_member','hs_books.id','=','hs_member.id')
    	->select('hs_books.*','hs_member.name')
    	->where('hs_member.make','=',1)
    	->where('hs_books.men','=',1)
    	->paginate(6);

    	$zuoping = DB::table('hs_books')
    	->join('hs_articles','hs_books.id','=','hs_articles.bid')
    	->join('hs_member','hs_books.aid','=','hs_member.id')
    	->select('hs_books.*','hs_member.name','hs_articles.title','hs_articles.content','hs_articles.time','hs_member.make')
    	->where('hs_member.make','=',1)
    	->get();
        
      

        $nan = DB::table('hs_books')
        ->join('hs_articles','hs_books.id','=','hs_articles.bid')
        ->join('hs_member','hs_books.aid','=','hs_member.id')
        ->select('hs_books.*','hs_member.name','hs_articles.title','hs_articles.content','hs_articles.time','hs_member.make')
        ->where('hs_books.men','=',0)
        ->paginate(10);
             
        $nv = DB::table('hs_books')
        ->join('hs_articles','hs_books.id','=','hs_articles.bid')
        ->join('hs_member','hs_books.aid','=','hs_member.id')
        ->select('hs_books.*','hs_member.name','hs_articles.title','hs_articles.content','hs_articles.time','hs_member.make')
        ->where('hs_books.men','=',1)
        ->get();   

         //友情链接    
        $friend = DB::table('hs_friend')->get();


      

        //轮播图片查询 
        $lunbo = DB::table('hs_books')->where('top',1)->paginate(6);

      

   return view('/index',['nansheng'=>$nansheng,'nvsheng'=>$nvsheng,'dasheng'=>$dasheng,'wanjie'=>$wanjie,'nanping'=>$nanping,'nvping'=>$nvping,'zuoping'=>$zuoping,'nan'=>$nan,'nv'=>$nv,'lunbo'=>$lunbo,'friend'=>$friend]);
	}


    


}
